package com.zhixin.fans.ks;

import com.androidnetworking.AndroidNetworking;
import com.tencent.bugly.Bugly;
import com.tencent.bugly.beta.Beta;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.PlatformConfig;
import com.zhixin.fans.ks.api.parser.DefaultParserFactory;
import com.zhixin.fans.ks.dagger.components.CoupleAppComponent;
import com.zhixin.fans.ks.dagger.components.DaggerCoupleAppComponent;
import com.zhixin.fans.ks.dagger.modules.CoupleAppModule;
import com.zhixin.fans.ks.ui.LaunchActivity;
import com.zhixin.fans.ks.ui.main.MainActivity;
import com.zhixin.fans.ks.ui.splash.SplashActivity;

import org.eenie.common.base.BaseApp;

public class CoupleApp extends BaseApp {

    private CoupleApp mCoupleApp;

    private CoupleAppComponent mCoupleAppComponent;

    @Override
    public void onCreate() {
        super.onCreate();
        mCoupleApp = this;

        injectCoupleApp();

        Beta.canShowApkInfo = true;
        Beta.enableNotification = true;
        Beta.largeIconId = R.mipmap.ic_launcher;
        Beta.smallIconId = R.mipmap.ic_launcher;
        Beta.defaultBannerId = R.mipmap.ic_launcher;
        Beta.canShowUpgradeActs.add(MainActivity.class);
        Beta.canNotShowUpgradeActs.add(SplashActivity.class);
        Beta.canNotShowUpgradeActs.add(LaunchActivity.class);
        Bugly.init(this, KeyConstant.KEY_BUGLY_APPID, true);
        Bugly.setAppChannel(this, BuildConfig.DEBUG ? "debug" : "release");


        AndroidNetworking.initialize(mCoupleApp, getApplicationComponent().getOkHttpClient());
        AndroidNetworking.setParserFactory(new DefaultParserFactory());

        UMConfigure.init(this, "5cb706c961f5643ba7000110", "Umeng_channel", UMConfigure.DEVICE_TYPE_PHONE, "");
        UMConfigure.setLogEnabled(true);
        PlatformConfig.setWeixin("wx9e5e8c7bb3f6960e", "9120d82b2bb62a555684da2d914ca3b3");
        PlatformConfig.setQQZone("101567851", "10f9b05964c062945a5b7b9521d33043");


    }


    public CoupleAppComponent getCoupleAppComponent() {
        return mCoupleAppComponent;
    }

    private void injectCoupleApp() {

        mCoupleAppComponent = DaggerCoupleAppComponent
                .builder()
                .coupleAppModule(new CoupleAppModule(this))
                .build();

        mCoupleAppComponent.inject(this);
    }

}
